package cn.tedu.v1.controller;

import cn.tedu.v1.exception.ServiceException;
import cn.tedu.v1.service.IUserService;
import cn.tedu.v1.vo.RegisterVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class SystemController {

    @Autowired
    private IUserService userService;

    @PostMapping("/register")
    public String registerUser(RegisterVo registerVo) {
        log.debug("收到用户注册信息:{}", registerVo);
        try {
            userService.registerUser(registerVo);
            return "注册完成";
        } catch (ServiceException e) {
            log.error("注册失败", e);
            return e.getMessage();
        }
    }
}
